package videostoreapp;

import java.sql.Timestamp;
import java.util.Calendar;
import java.util.Iterator;
import java.util.List;

import videostoreapp.Catalogue.CatalogueInfo;
import videostoreapp.Customer.CustomerInfo;
//import videostoreapp.Delivery.DeliveryInfo;
import videostoreapp.Order.OrderInfo;
import videostoreapp.Order.OrderLineInfo;
//import videostoreapp.Stock.StockInfo;
import videostoreapp.dataobjects.CatalogueDO;
import videostoreapp.dataobjects.CustomerDO;
//import videostoreapp.dataobjects.DeliveryDO;
import videostoreapp.dataobjects.OrderDO;
//import videostoreapp.dataobjects.StockDO;

public class TestDriver {

	/**
	 * @param args
	 * @throws ApplicationException 
	 */
	public static void main(String[] args) throws ApplicationException {
		
        Customer customer = new CustomerDO();
        CustomerInfo cust = new CustomerInfo(0, "Cust 1", "Address 1");
        int cId1 = customer.createCustomer(cust);
        cust = new CustomerInfo(0, "Cust 2", "Address 2");
        int cId2 = customer.createCustomer(cust);
        
        System.out.println(cId1 + ", " + cId2);
        
        CustomerInfo cif = customer.getCustomerById(cId1);
        System.out.println(cif.name + ", " + cif.address);

        cif.address = "Address N";
        customer.modifyCustomer(cif);
        
        CustomerInfo cif2 = customer.getCustomerById(cId1);
        System.out.println(cif2.name + ", " + cif2.address);
        

        
        Catalogue catalogue = new CatalogueDO();
        CatalogueInfo cat = new CatalogueInfo(0, "C0001", "Title 1", "Director 1", "Genre 1", 10.99f);
        int catId1 = catalogue.createVideo(cat);
        cat = new CatalogueInfo(0, "C0002", "Title 2", "Director 2", "Genre 2", 20.99f);
        int catId2 = catalogue.createVideo(cat);
        cat = new CatalogueInfo(0, "C0003", "Title 3", "Director 3", "Genre 3", 30.99f);
        int catId3 = catalogue.createVideo(cat);
        System.out.println("(" + catId1 + "," + catId2 + "," + catId3 + ")");
        cat = catalogue.getVideoById(catId1);
        System.out.println(catId1 + ": " + cat.title);
        cat = catalogue.getVideoByCatalogueNumber("C0001");
        System.out.println("C0001 " + cat.title + "," + cat.catNo);
        List<CatalogueInfo> al = catalogue.getVideosByDirector("Director 1");
        Iterator<CatalogueInfo> itr = al.iterator();
        while(itr.hasNext()){
        	System.out.println(itr.next().title);
        }
        al = catalogue.getVideosByGenre("Genre 1");
        itr = al.iterator();
        while(itr.hasNext()){
        	System.out.println(itr.next().title);
        }
        /*
        Stock stock = new StockDO();
        StockInfo item = new StockInfo(0, 1, "Sydney", 10);
        int itemId1 = stock.createItem(item);
        item = new StockInfo(0, catId1, "Sydney", 10);
        int itemId2 = stock.createItem(item);
        item = new StockInfo(0, catId2, "Sydney", 10);
        int itemId3 = stock.createItem(item);
        item = new StockInfo(0, catId3, "Sydney", 10);
        int itemId4 = stock.createItem(item);
        item = stock.getItemById(itemId1);
        List<StockInfo> items = stock.getItemByWarehouse("Sydney");
        int H1S = stock.getHoldingByWarehouse(catId1, "Sydney");
        H1S = stock.bought(catId1, 10, "Sydney");
        int H1M = stock.bought(catId1, 10, "Melbourne");
        H1S = stock.sold(catId1, 10, "Sydney");
        */
        Order order = new OrderDO();
        OrderInfo ord = new OrderInfo(0, cId1, 0.0f, new Timestamp(Calendar.getInstance().getTimeInMillis()), "Sydney", "Pitt St", OrderInfo.OrderStatus.PENDING);
        OrderLineInfo[] ol = new OrderLineInfo[2];
        ol[0] = new OrderLineInfo(0, 0, catId1, 1);
        ol[1] = new OrderLineInfo(0, 0, catId2, 1);
        ord.videos = ol;
        int oId1 = order.createOrder(ord);
        ord = order.getOrderById(oId1);
/*
        Delivery delivery = new DeliveryDO();
        DeliveryInfo del = new DeliveryInfo(0, oId1, "Sydney", new Timestamp(Calendar.getInstance().getTimeInMillis()), OrderInfo.OrderStatus.ACCEPTED);
        int delId1 = delivery.createDelivery(del);
        del = delivery.getDeliveryById(delId1);

        order.submitOrder(oId1);*/
	}

}
